package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.StorageCommonVo;
import com.cskaoyan.service.StorageService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * <h1> 小程序端 WxStorage Controller </h1>
 * Created by GaoJia
 * Date  2021/10/22 20:23
 */
@RestController
@RequestMapping("wx/storage")
public class WxStorageController {

    @Resource
    StorageService storageService;

    /**
     * <h2> 小程序端 文件上传 </h2>
     */
    @PostMapping("upload")
    public BaseRespVo upload(MultipartFile file) throws IOException {
        /**
         *
         * TODO 差点忘了进行异常处理了
         *
         * {"errno":401,"errmsg":"参数不对"}
         * */
        System.out.println("enter WxStorageController");
        StorageCommonVo storageCommonVo = storageService.create(file);
        return BaseRespVo.ok(storageCommonVo);
    }
}
